#define _CRT_SECURE_NO_WARNINGS 1 

#include <iostream>
#include <string>
using namespace std;

class Solution
{
public:
    string modifyString(string s)
    {
        int n = s.size();
        for (int i = 0; i < n; i++)
        {
            if (s[i] == '?')
            {
                for (char ch = 'a'; ch <= 'z'; ch++)
                {
                    if ((i == 0 || ch != s[i - 1]) && (i == n - 1 || ch != s[i + 1]))
                    {
                        s[i] = ch;
                        break;
                    }
                }
            }

        }
        return s;
    }
};

int main()
{
    Solution sol;
    string s, ret;
    s.push_back('?');
    s.push_back('s');
    s.push_back('g');
    s.push_back('?');
    s.push_back('r');
    s.push_back('h');
    s.push_back('?');
    s.push_back('l');
    s.push_back('?');

    ret = sol.modifyString(s);

    for (auto e : s)
    {
        cout << e << " ";
    }
    cout << endl;

    for (auto e : ret)
    {
        cout << e << " ";
    }
    cout << endl;
    return 0;
}